home *** CD-ROM | disk | FTP | other *** search
-
- #include "Neural Network.h"
- #include <math.h>
-
- /*---- Debuging prototypes and structs ----*/
- Stestnet(NeuralNet *);
- FILE * Jac;
- /*-----------------------------------------*/
-
- /*** Global structures *****************/
- NeuralNet * theNet; /* pointer to a NeuralNet structure */
- NeuralNet Nets[ActiveNets];/* array of available model structures */
-
- DTypeVector yData; /* output values of neural network, is (#Obs)x1 */
- DTypeMatrix XData; /* input values of neural network, is (#Obs) x (#Input Neurons) */
- DTypeMatrix Jac_T; /* transpose of Jacobian matrix, is (#Parms)x(#Obs)
- Parameters are arranged such that the (1,1) element of W[0]
- is in the first row, and the (N,N) element of W[OutLayer] is
- in the last row */
- DTypeVector Pi, Diag; /* vectors for pi and diagonal values from QR decomposition,
- are (#Parms)x1 */
- DTypeVector Resid; /* residuals at current value, used with Jacobian to calc next
- step, is (#Obs)x1 like yData */
- DTypeVector gradSS; /* gradient of the SS function, is (#Parms)x1, used in stop criteria */
- DTypeMatrix Phi, T2; /* temporary storage for matrix products used in calculation of Jacobian */
- DTypeVector dSquash[MaxLay]; /* vector of derivative of the squashing function */
- DTypeVector Alpha[MaxLay]; /* vector of values after applying squashing function */
-
- /***************************************************************************/
- main()
- {
- theNet = &Nets[0];
- printf("this is test\n");
- if((Jac = fopen("Testdata:Jacobian","w"))==NULL)
- { printf("Can't open file");
- ExitToShell();
- }
-
- SetupNetDefaults();
- SetTestNet(theNet);
- AllotInitNewNetWeights();
- testData(theNet);
-
- Estimate();
- theNet->method = HookeJeeves;
- Estimate();
-
- fclose(Jac);
-
- }
-
- /***************************************************************************/
-
-
- Estimate()
- {
- int termcode;
-
- HLock(yData.cells);
- HLock(XData.cells);
-
- switch(theNet->method)
- { case BackProp:
- { break;
- }
- case SimAnn:
- { break;
- }
- case HookeJeeves:
- { AllotSearchWorkSpace();
- LockSearchWorkSpace();
- termcode = do_HookeJeeves();
- UnlockSearchWorkSpace();
- break;
- }
- case GaussNew:
- { AllotGradientWorkSpace();
- LockGradientWorkSpace();
- termcode = do_GaussNewton();
- UnlockGradientWorkSpace();
- break;
- }
- case qGaussNew:
- { AllotGradientWorkSpace();
- LockGradientWorkSpace();
- termcode = do_quasiGaussNewton();
- UnlockGradientWorkSpace();
- break;
- }
- default:
- NotYetAvail();
- }
-
- HUnlock(yData.cells);
- HUnlock(XData.cells);
-
- return(termcode);
- }